package models

import (
	"go-mgdms/internal/common/config"
)

// AdminModel 管理员数据模型
type AdminModel struct {
	ID            uint    `gorm:"type:int;primaryKey;autoIncrement;unsigned;comment:ID" json:"id"`
	Username      string  `gorm:"type:varchar(20);not null;default:'';comment:用户名" json:"username"`
	Nickname      string  `gorm:"type:varchar(50);not null;default:'';comment:昵称" json:"nickname"`
	Avatar        string  `gorm:"type:varchar(255);not null;default:'';comment:头像" json:"avatar"`
	Email         string  `gorm:"type:varchar(50);not null;default:'';comment:邮箱" json:"email"`
	Mobile        string  `gorm:"type:varchar(11);not null;default:'';comment:手机" json:"mobile"`
	LoginFailure  uint8   `gorm:"type:tinyint;unsigned;not null;default:0;comment:登录失败次数" json:"login_failure"`
	LastLoginTime *uint64 `gorm:"type:bigint;unsigned;comment:上次登录时间" json:"last_login_time"`
	LastLoginIP   string  `gorm:"type:varchar(50);not null;default:'';comment:上次登录IP" json:"last_login_ip"`
	Password      string  `gorm:"type:varchar(255);not null;default:'';comment:密码" json:"password"`
	Salt          string  `gorm:"type:varchar(30);not null;default:'';comment:密码盐（废弃待删）" json:"salt"`
	Motto         string  `gorm:"type:varchar(255);not null;default:'';comment:签名" json:"motto"`
	Status        string  `gorm:"type:varchar(30);not null;default:'';comment:状态:enable=启用,disable=禁用" json:"status"`
	UpdateTime    *uint64 `gorm:"type:bigint;unsigned;comment:更新时间" json:"update_time"`
	CreateTime    *uint64 `gorm:"type:bigint;unsigned;comment:创建时间" json:"create_time"`
}

// TableName 设置表名
func (AdminModel) TableName() string {
	return config.GetTablePrefix() + "admin"
}
